Ubuntu mounts a new hard disk

0 view the currently mounted hard disks. You can see that only sda hard disks are used. ...

0 view the currently mounted hard disks. You can see that only sda hard disks are used.

dacent@dacent:~$ df -lh Filesystem Size Used Avail Use% Mounted on udev 63G 0 63G 0% /dev tmpfs 13G 9.6M 13G 1% /run /dev/mapper/dacent--vg-root 219G 2.0G 206G 1% / tmpfs 63G 0 63G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 63G 0 63G 0% /sys/fs/cgroup /dev/sda1 472M 107M 342M 24% /boot tmpfs 13G 0 13G 0% /run/user/1000 tmpfs 13G 0 13G 0% /run/user/1001

1 find a new hard disk, find a new hard disk. New sdb hard disk is found here.

sudo fdisk -l Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 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: 0x1213cdba Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 999423 997376 487M 83 Linux /dev/sda2 1001470 468860927 467859458 223.1G 5 Extended /dev/sda5 1001472 468860927 467859456 223.1G 8e Linux LVM Partition 2 does not start on physical sector boundary. Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 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

2 create a new partition for the sdb hard disk

linlf@dacent:~$ sudo fdisk /dev/sdb Welcome to fdisk (util-linux 2.27.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0x6d19375b. Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (1-4, default 1): First sector (2048-1953525167, default 2048): Last sector, +sectors or +size (2048-1953525167, default 1953525167): Created a new partition 1 of type 'Linux' and of size 931.5 GiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.

3 view new partition of new hard disk

sudo fdisk -l /dev/sdb Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 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: dos Disk identifier: 0x6d19375b Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 1953525167 1953523120 931.5G 83 Linux

4 change the file format of the new partition to ext4

linlf@dacent:~$ sudo mkfs.ext4 /dev/sdb1 mke2fs 1.42.13 (17-May-2015) Creating filesystem with 244190390 4k blocks and 61054976 inodes Filesystem UUID: 938e6783-d5cb-4e38-98e2-e8e2b0918587 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done

5 view the file type and device number of the new partition

linlf@dacent:~$ sudo blkid /dev/sdb1 /dev/sdb1: UUID="928e6783-d5cb-4e38-98e2-e8e2b0918587" TYPE="ext4" PARTUUID="6219375b-01"

6. After we have a new partition, we can start to mount it. Because I want to use more storage space, I mount it in the / home directory. Please note that the same directory cannot be mounted in different partitions.

dacent@dacent:~$ sudo mkdir /new dacent@dacent:~$ sudo mount /dev/sdb1 /new dacent@dacent:~$ sudo cp -r /home/* /new dacent@dacent:~$ dacent@dacent:~$ ls /new/ (Check whether the copy is successful) dacent linlf dacent@dacent:~$ sudo umount /dev/sdb1 dacent@dacent:~$ sudo mount /dev/sdb1 /home (Successfully attached)

7 finally, to make the new hard disk boot and mount automatically, add a line sudo vi /etc/fstab in / etc/fstab

UUID=928e6783-d5cb-4e38-98e2-e8e2b0918587 /home ext4 defaults 0 2

8 restart to verify the last step.

reboot

9 February 2020, 13:12 | Views: 7011

Add new comment

For adding a comment, please log in
or create account

0 comments