Select Page

These steps must be done when new blank disk is created:

  • create new disk according your needs
  • attach it to the instance
  • ssh instance
  • find disk name:
    • ls -lt /dev/disk/by-id/*
      • new disk will be on the top and its name will look like ‘google-yourdiskname’
  • create partition (on disk smaller then 2TB):
    • sudo fdisk /dev/disk/by-id/google-yourdiskname
      • commands:
        • m (help)
        • p (list partittion table)
          • for new empty disk list must be empty like this:
            Disk /dev/disk/by-id/google-mynewdisk: 2 TiB, 2199023255552 bytes, 4294967296 sectors
            Units: sectors of 1 * 512 = 512 bytes
            Sector size (logical/physical): 512 bytes / 4096 bytes
            I/O size (minimum/optimal): 4096 bytes / 4096 bytes
            Disklabel type: dos
            Disk identifier: 0x........
        • n (create new partiton) + p (primary) + ENTERs on other settings
        • p (see partitions)
          • now you should see your new partition:
            Disk /dev/disk/by-id/google-mynewdisk: 2 TiB, 2199023255552 bytes, 4294967296 sectors
            Units: sectors of 1 * 512 = 512 bytes
            Sector size (logical/physical): 512 bytes / 4096 bytes
            I/O size (minimum/optimal): 4096 bytes / 4096 bytes
            Disklabel type: dos
            Disk identifier: 0x........
            
            Device                                       Boot Start        End    Sectors Size Id Type
            /dev/disk/by-id/google-mynewdisk-part1       2048 4294967294 4294965247   2T 83 Linux
        • w (save changes + exists fdisk)
  • create partition (on disk bigger then 2 TB):
    • follow these instructions: http://magicmonster.com/kb/os/linux/large_hdd.html
    • sudo parted yourdisk

      (yourdisk as /dev/sbx or as /dev/disk/by-id/yourdisk)

      • print (show partitions)
        • output will look like follows:
          GNU Parted 3.2
          Using /dev/sdb
          Welcome to GNU Parted! Type 'help' to view a list of commands.
          (parted) print
          Error: /dev/sdb: unrecognised disk label
          Model: Google PersistentDisk (scsi)
          Disk /dev/sdb: 6597GB
          Sector size (logical/physical): 512B/4096B
          Partition Table: unknown
          Disk Flags: 
      • mklabel gpt
      • mkpart (create partition)
        • partition name?
          • part1
        • File system type? [ext2]?
          • ext4
        • Start?
          • 0%
        • End?
          • 100%
      • print
        • output will now look like this:
          (parted) print
          Model: Google PersistentDisk (scsi)
          Disk /dev/sdb: 6597GB
          Sector size (logical/physical): 512B/4096B
          Partition Table: gpt
          Disk Flags:
          
          Number Start End Size File system Name Flags
          1 1049kB 6597GB 6597GB ext4 part1
      • quit
  • check again disk and partition:
    • ls -lt /dev/disk/by-id/*
      • beside ‘google-yourdiskname’ you will see also ‘google-yourdiskname-part1’ !
  • format filesystem (on partition!):
    • sudo mkfs.ext4 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/disk/by-id/google-yourdiskname-part1
  • make mounting point:
    • sudo mkdir /mnt/pointname
  • mount filesystem (we mount partition!):
    • sudo mount -o discard,defaults /dev/disk/by-id/google-yourdiskname-part1 /mnt/pointname
  • allow write access to all:
    • sudo chmod a+w /mnt/pointname
  • add disk to fstab to be automatically mounted after reboot:
    • echo '/dev/disk/by-id/google-yourdiskname-part1 /mnt/pointname ext4 discard,defaults 1 1' | sudo tee -a /etc/fstab