id: 12610    nodeId: 12610    type: General    point: 168.0    linkPoint: .0    maker: cella    permission: linkable    made at: 2019.11.01 04:21    edited at: 2019.11.06 02:50
external HDD on Ubuntu
https://help.ubuntu.com/community/InstallingANewHardDrive
https://help.ubuntu.com/community/UsingUUID
-----------------------
partition and format
-----------------------

$ sudo fdisk -l
Disk /dev/nvme0n1: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 1F60BF2C-F030-407B-9D00-334E453C697F
...

Disk /dev/sda: 3.7 TiB, 4000787030016 bytes, 7814037168 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

$ sudo parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
(parted) unit TB
(parted) mkpart
Partition name? []? data
File system type? [ext2]? ext4
Start? 0
End? 4
(parted) print
Model: ATA WDC WD40EZRZ-00G (scsi)
Disk /dev/sda: 4.00TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 0.00TB 4.00TB 4.00TB ext4 data

(parted) quit
Information: You may need to update /etc/fstab.

$ sudo fdisk -l
Disk /dev/nvme0n1: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 1F60BF2C-F030-407B-9D00-334E453C697F
...
Disk /dev/sda: 3.7 TiB, 4000787030016 bytes, 7814037168 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: gpt
Disk identifier: 84C7D8BF-B2AD-4148-A8A3-1C83772DA8AB

Device Start End Sectors Size Type
/dev/sda1 2048 7814035455 7814033408 3.7T Linux filesystem

$ sudo mkfs -t ext4 /dev/sda1
mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 976754176 4k blocks and 244195328 inodes
Filesystem UUID: 16d6fc51-ac58-478a-98b4-f5ee3d5fbccc
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848, 512000000, 550731776, 644972544

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

-----------------------
reduce reserved space
-----------------------
$ sudo tune2fs -l /dev/sda1
...
Inode count: 244195328
Block count: 976754176
Reserved block count: 48837708
Free blocks: 961137397
Free inodes: 244195317
...

$ sudo tune2fs -m 1 /dev/sda1
tune2fs 1.44.1 (24-Mar-2018)
Setting reserved blocks percentage to 1% (9767541 blocks)

$ sudo tune2fs -l /dev/sda1
...
Inode count: 244195328
Block count: 976754176
Reserved block count: 9767541
Free blocks: 961137397
Free inodes: 244195317
...

-----------------------
mount
-----------------------

// mount point
$ sudo mkdir /media/hdd0

// find UUID; currently UUID is preferred than /dev/... in fstab
$ sudo blkid
/dev/nvme0n1p1: UUID="87A0-AE55" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="95402b50-bfd9-4922-8e69-21a6617a2095"
/dev/nvme0n1p2: UUID="Iw0oTd-mZMn-4rf8-dOn3-4dSL-Lj5f-R4P2kl" TYPE="LVM2_member" PARTUUID="dbcfad08-c734-4413-9e4e-469c65bffe85"
/dev/mapper/ubuntu--vg-root: UUID="be0f7bbb-4a28-4d43-8ce8-038fcab09eef" TYPE="ext4"
/dev/mapper/ubuntu--vg-swap_1: UUID="48adf593-5d0a-40af-b2f4-94067c6a6f79" TYPE="swap"
/dev/sda1: UUID="16d6fc51-ac58-478a-98b4-f5ee3d5fbccc" TYPE="ext4" PARTLABEL="data" PARTUUID="2675abb4-7d93-42b7-b3c2-8910a6a9ee6d"
/dev/nvme0n1: PTUUID="1f60bf2c-f030-407b-9d00-334e453c697f" PTTYPE="gpt"

// add a line at the end of fstab to mount automatically during boot
$ sudo vi /etc/fstab
/dev/mapper/ubuntu--vg-root / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=87A0-AE55 /boot/efi vfat umask=0077 0 1
/dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0
UUID=16d6fc51-ac58-478a-98b4-f5ee3d5fbccc /media/hdd0 ext4 defaults 0 2

Return to 마실촌 농장 - 토마토 따기 체험 or external HDD on Ubuntu