bryanbocao / awesome-cmd-cheatsheets

Quick search the commands you need.
3 stars 1 forks source link

Mounting a New Hard Drive on Linux (and also Accessed on Mac) #22

Closed bryanbocao closed 1 year ago

bryanbocao commented 1 year ago

List all disk devices

lsblk
(base) brcao@aw2:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0     4K  1 loop /snap/bare/5
loop1    7:1    0  73.9M  1 loop /snap/core22/864
loop2    7:2    0 240.8M  1 loop /snap/gnome-3-34-1804/24
loop3    7:3    0  40.9M  1 loop /snap/snapd/20092
loop4    7:4    0  55.7M  1 loop /snap/core18/2785
loop5    7:5    0  40.9M  1 loop /snap/snapd/20290
loop6    7:6    0   497M  1 loop /snap/gnome-42-2204/141
loop7    7:7    0 496.9M  1 loop /snap/gnome-42-2204/132
loop8    7:8    0  55.7M  1 loop /snap/core18/2790
loop9    7:9    0  73.9M  1 loop /snap/core22/858
loop10   7:10   0  49.8M  1 loop /snap/snap-store/433
loop11   7:11   0 218.4M  1 loop /snap/gnome-3-34-1804/93
loop12   7:12   0  91.7M  1 loop /snap/gtk-common-themes/1535
loop13   7:13   0  12.3M  1 loop /snap/snap-store/959
loop14   7:14   0  62.1M  1 loop /snap/gtk-common-themes/1506
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
└─sda2   8:2    0   931G  0 part /
sdb      8:16   0   1.8T  0 disk /aw2data
sdg      8:96   0   3.7T  0 disk 
sr0     11:0    1  1024M  0 rom  

Note sdg 8:96 0 3.7T 0 disk is the target new disk, which is not shown by df -h:

df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             32G     0   32G   0% /dev
tmpfs           6.3G  3.3M  6.3G   1% /run
/dev/sda2       916G  465G  405G  54% /
tmpfs            32G  531M   31G   2% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs            32G     0   32G   0% /sys/fs/cgroup
/dev/loop0      128K  128K     0 100% /snap/bare/5
/dev/loop1       74M   74M     0 100% /snap/core22/864
/dev/loop2      241M  241M     0 100% /snap/gnome-3-34-1804/24
/dev/loop3       41M   41M     0 100% /snap/snapd/20092
/dev/loop4       56M   56M     0 100% /snap/core18/2785
/dev/loop5       41M   41M     0 100% /snap/snapd/20290
/dev/loop6      497M  497M     0 100% /snap/gnome-42-2204/141
/dev/loop7      497M  497M     0 100% /snap/gnome-42-2204/132
/dev/loop9       74M   74M     0 100% /snap/core22/858
/dev/loop8       56M   56M     0 100% /snap/core18/2790
/dev/loop10      50M   50M     0 100% /snap/snap-store/433
/dev/loop13      13M   13M     0 100% /snap/snap-store/959
/dev/loop12      92M   92M     0 100% /snap/gtk-common-themes/1535
/dev/loop14      63M   63M     0 100% /snap/gtk-common-themes/1506
/dev/loop11     219M  219M     0 100% /snap/gnome-3-34-1804/93
/dev/sda1       511M  6.1M  505M   2% /boot/efi
/dev/sdb        1.8T  1.3T  490G  72% /aw2data
tmpfs           6.3G   20K  6.3G   1% /run/user/125
tmpfs           6.3G   84K  6.3G   1% /run/user/1000
sudo mkfs.exfat -n eData4TB /dev/sdg

(sudo mkfs.ext4 /dev/sdg for ext4) Note exfat works for both Ubuntu and Mac and eData4TB is the label name:

(base) brcao@aw2:~$ sudo mkfs.exfat -n eData4TB /dev/sdg
mkexfatfs 1.3.0
Creating... done.
Flushing... done.
File system created successfully.

Create a folder /media/brcao/eData4TB where you want to mount the new hard drive:

sudo mkdir /media/brcao/eData4TB
sudo vim /etc/fstab

Append the following line to the end of the file:

/dev/sdg        /media/brcao/eData4TB   exfat   defaults        0 0

Mount the hard drive:

sudo mount /media/brcao/eData4TB
(base) brcao@aw2:~$ sudo mount /media/brcao/eData4TB
FUSE exfat 1.3.0

Then it can be accessed by the system:

(base) brcao@aw2:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             32G     0   32G   0% /dev
tmpfs           6.3G  3.3M  6.3G   1% /run
/dev/sda2       916G  465G  405G  54% /
tmpfs            32G  704M   31G   3% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs            32G     0   32G   0% /sys/fs/cgroup
/dev/loop0      128K  128K     0 100% /snap/bare/5
/dev/loop1       74M   74M     0 100% /snap/core22/864
/dev/loop2      241M  241M     0 100% /snap/gnome-3-34-1804/24
/dev/loop3       41M   41M     0 100% /snap/snapd/20092
/dev/loop4       56M   56M     0 100% /snap/core18/2785
/dev/loop5       41M   41M     0 100% /snap/snapd/20290
/dev/loop6      497M  497M     0 100% /snap/gnome-42-2204/141
/dev/loop7      497M  497M     0 100% /snap/gnome-42-2204/132
/dev/loop9       74M   74M     0 100% /snap/core22/858
/dev/loop8       56M   56M     0 100% /snap/core18/2790
/dev/loop10      50M   50M     0 100% /snap/snap-store/433
/dev/loop13      13M   13M     0 100% /snap/snap-store/959
/dev/loop12      92M   92M     0 100% /snap/gtk-common-themes/1535
/dev/loop14      63M   63M     0 100% /snap/gtk-common-themes/1506
/dev/loop11     219M  219M     0 100% /snap/gnome-3-34-1804/93
/dev/sda1       511M  6.1M  505M   2% /boot/efi
/dev/sdb        1.8T  1.3T  490G  72% /aw2data
tmpfs           6.3G   20K  6.3G   1% /run/user/125
tmpfs           6.3G   84K  6.3G   1% /run/user/1000
/dev/sdg        3.7T  121M  3.7T   1% /media/brcao/eData4TB
bryanbocao commented 8 hours ago

Update on Y2024M11D15Fri

Ubuntu CMD exfat

Mounting a new backup hard drive for both Ubuntu and Mac.

Before inserting the new hard drive:

(base) brcao@night:~/Repos$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0     4K  1 loop /snap/bare/5
loop1    7:1    0  12.2M  1 loop /snap/snap-store/1216
loop2    7:2    0  55.7M  1 loop /snap/core18/2829
loop4    7:4    0 218.4M  1 loop /snap/gnome-3-34-1804/93
loop5    7:5    0  91.7M  1 loop /snap/gtk-common-themes/1535
loop6    7:6    0 240.8M  1 loop /snap/gnome-3-34-1804/24
loop7    7:7    0  73.9M  1 loop /snap/core22/1663
loop9    7:9    0 505.1M  1 loop /snap/gnome-42-2204/176
loop10   7:10   0  12.9M  1 loop /snap/snap-store/1113
loop11   7:11   0  38.8M  1 loop /snap/snapd/21465
loop12   7:12   0  62.1M  1 loop /snap/gtk-common-themes/1506
loop13   7:13   0  38.8M  1 loop /snap/snapd/21759
loop14   7:14   0 504.2M  1 loop /snap/gnome-42-2204/172
loop15   7:15   0  55.4M  1 loop /snap/core18/2846
loop16   7:16   0  74.3M  1 loop /snap/core22/1621
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0   1.1G  0 part 
├─sda2   8:2    0     2G  0 part 
└─sda3   8:3    0 928.5G  0 part 
sdb      8:16   0 223.6G  0 disk 
├─sdb1   8:17   0   512M  0 part /boot/efi
└─sdb2   8:18   0 223.1G  0 part /

After inserting the new hard drive:

New drive

sdc 8:32 0 16.4T 0 disk

(base) brcao@night:~/Repos$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0     4K  1 loop /snap/bare/5
loop1    7:1    0  12.2M  1 loop /snap/snap-store/1216
loop2    7:2    0  55.7M  1 loop /snap/core18/2829
loop4    7:4    0 218.4M  1 loop /snap/gnome-3-34-1804/93
loop5    7:5    0  91.7M  1 loop /snap/gtk-common-themes/1535
loop6    7:6    0 240.8M  1 loop /snap/gnome-3-34-1804/24
loop7    7:7    0  73.9M  1 loop /snap/core22/1663
loop9    7:9    0 505.1M  1 loop /snap/gnome-42-2204/176
loop10   7:10   0  12.9M  1 loop /snap/snap-store/1113
loop11   7:11   0  38.8M  1 loop /snap/snapd/21465
loop12   7:12   0  62.1M  1 loop /snap/gtk-common-themes/1506
loop13   7:13   0  38.8M  1 loop /snap/snapd/21759
loop14   7:14   0 504.2M  1 loop /snap/gnome-42-2204/172
loop15   7:15   0  55.4M  1 loop /snap/core18/2846
loop16   7:16   0  74.3M  1 loop /snap/core22/1621
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0   1.1G  0 part 
├─sda2   8:2    0     2G  0 part 
└─sda3   8:3    0 928.5G  0 part 
sdb      8:16   0 223.6G  0 disk 
├─sdb1   8:17   0   512M  0 part /boot/efi
└─sdb2   8:18   0 223.1G  0 part /
sdc      8:32   0  16.4T  0 disk 
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:    20.04
Codename:   focal
sudo mkfs.exfat -n Data18TB /dev/sdc
mkexfatfs 1.3.0
Creating... done.
Flushing... done.
File system created successfully.
(base) brcao@night:/media/brcao$ sudo mkdir Data18TB
sudo vim /etc/fstab

Append the following line to the end of the file:

/dev/sdc        /media/brcao/Data18TB   exfat   default 0       0

Mount the hard drive:

sudo mount /media/brcao/Data18TB
FUSE exfat 1.3.0

Then it can be accessed by the system:

(base) brcao@night:/media/brcao$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             16G     0   16G   0% /dev
tmpfs           3.2G  2.0M  3.2G   1% /run
/dev/sdb2       219G   56G  153G  27% /
tmpfs            16G     0   16G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs            16G     0   16G   0% /sys/fs/cgroup
/dev/loop0      128K  128K     0 100% /snap/bare/5
/dev/loop2       56M   56M     0 100% /snap/core18/2829
/dev/loop4      219M  219M     0 100% /snap/gnome-3-34-1804/93
/dev/loop5       92M   92M     0 100% /snap/gtk-common-themes/1535
/dev/loop11      39M   39M     0 100% /snap/snapd/21465
/dev/loop6      241M  241M     0 100% /snap/gnome-3-34-1804/24
/dev/loop10      13M   13M     0 100% /snap/snap-store/1113
/dev/loop9      506M  506M     0 100% /snap/gnome-42-2204/176
/dev/loop12      63M   63M     0 100% /snap/gtk-common-themes/1506
/dev/loop14     505M  505M     0 100% /snap/gnome-42-2204/172
/dev/loop13      39M   39M     0 100% /snap/snapd/21759
/dev/sdb1       511M  6.1M  505M   2% /boot/efi
tmpfs           3.2G   16K  3.2G   1% /run/user/125
/dev/loop15      56M   56M     0 100% /snap/core18/2846
/dev/loop16      75M   75M     0 100% /snap/core22/1621
/dev/loop1       13M   13M     0 100% /snap/snap-store/1216
/dev/loop7       74M   74M     0 100% /snap/core22/1663
tmpfs           3.2G  8.0K  3.2G   1% /run/user/1000
/dev/sdc         17T  541M   17T   1% /media/brcao/Data18TB

Mac Disk Utility exfat

But later I got this error message when I attempted to mount it on my MacBook:

Screen Shot 2024-11-15 at 3 19 43 PM

When I format the data by the Disk Utility tool directly:

Screen Shot 2024-11-15 at 3 38 46 PM Screen Shot 2024-11-15 at 3 39 23 PM Screen Shot 2024-11-15 at 3 39 36 PM

The hard drive works normally on Mac, including accessing, copying and pasting files into it. Even later it works on my Ubuntu 20 machines, including accessing, copying and pasting files into it.


Summary

Steps Ubuntu Mac
Ubuntu CMD exfat Writable✅ Unwritable❌
Ubuntu CMD exfat -> Mac Disk Utility exfat Writable✅ Writable✅
Mac Disk Utility exfat TODO🔄 TODO🔄