Add Persistance Disk

於Compute Engine上可以快速的申請一顆Disk,並且分派給某一檯主機使用,下面為Disk申請確認後之掛載動作:

Step1: 確認Filesystem並建立欲掛載Disk之資料匣

$ df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda1       9.9G  9.9G     0 100% /

tmpfs           1.8G     0  1.8G   0% /dev/shm

$ sudo mkdir -p /mnt/pd0

$ ls -l /dev/disk/by-id/google-*

lrwxrwxrwx. 1 root root  9 2013-12-23 06:55 /dev/disk/by-id/google-php-server -> ../../sda

lrwxrwxrwx. 1 root root  9 2013-12-23 11:22 /dev/disk/by-id/google-php-server-data-disk1 -> ../../sdb

lrwxrwxrwx. 1 root root 10 2013-12-23 06:55 /dev/disk/by-id/google-php-server-part1 -> ../../sda1

Step2: 格式化與掛載前設定

$ sudo /usr/share/google/safe_format_and_mount -m "mkfs.ext4 -F" /dev/disk/by-id/google-php-server-data-disk1 /mnt/pd0

safe_format_and_mount: Running: fsck.ext4 -a /dev/disk/by-id/google-php-server-data-disk1

safe_format_and_mount: fsck.ext4: Bad magic number in super-block while trying to open /dev/disk/by-id/google-php-server-data-disk1

safe_format_and_mount: /dev/disk/by-id/google-php-server-data-disk1:

safe_format_and_mount: The superblock could not be read or does not describe a correct ext2

safe_format_and_mount: ....

safe_format_and_mount: This filesystem will be automatically checked every 21 mounts or

safe_format_and_mount: 180 days, whichever comes first.  Use tune2fs -c or -i to override.

safe_format_and_mount: Running: mount -o defaults /dev/disk/by-id/google-php-server-data-disk1 /mnt/pd0

Step3: 掛載已經格式化之Disk

$ sudo mount -o defaults /dev/disk/by-id/google-php-server-data-disk1 /mnt/pd0

mount: /dev/sdb already mounted or /mnt/pd0 busy

mount: according to mtab, /dev/sdb is already mounted on /mnt/pd0

Step4: 填入fstab中,讓開機自動帶起
UUID=a8cf6ab7-92fb-42c6-b95f-d437f94aaf98 / ext4    defaults,barrier=0 1 1
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/sdb        /mnt/pd0        ext4    defaults        1       1