Ubuntu üzerinde ikincil bir disk ekledikten sonra bu diski kalıcı olarak bir klasöre mount etmek için aşağıdaki yolları izleyebilirsiniz.

Disklerimizi kontrol ediyoruz.

lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0                         2:0    1    4K  0 disk 
loop0                       7:0    0   55M  1 loop /snap/core18/1880
loop1                       7:1    0 55.5M  1 loop /snap/core18/2284
loop2                       7:2    0 61.9M  1 loop /snap/core20/1328
loop3                       7:3    0 61.9M  1 loop /snap/core20/1361
loop4                       7:4    0 67.2M  1 loop /snap/lxd/21835
loop5                       7:5    0 43.6M  1 loop /snap/snapd/14978
loop6                       7:6    0 67.9M  1 loop /snap/lxd/22526
sda                         8:0    0  800G  0 disk 
sdb                         8:16   0  200G  0 disk 
├─sdb1                      8:17   0    1M  0 part 
├─sdb2                      8:18   0    1G  0 part /boot
└─sdb3                      8:19   0  199G  0 part 
  └─ubuntu--vg-ubuntu--lv 253:0    0 99.5G  0 lvm  /
sr0                        11:0    1 1024M  0 rom  

Ekleyeceğimiz disk sda diski. Öncelikle partition oluşturuyoruz

fdisk /dev/sda
Welcome to fdisk (util-linux 2.34).
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 0x2ecefee3.

Command (m for help): p
Disk /dev/sda: 800 GiB, 858993459200 bytes, 1677721600 sectors
Disk model: Virtual Disk    
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: 0x2ecefee3

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p

Bu kısımda daha önce bu diskte partition olmadığı için default 1 olarak geliyor. Enter tuşuna basıp geçiyoruz. Default 1 olarak alıyor.

Partition number (1-4, default 1): 

Tekrar ENTER

First sector (2048-1677721599, default 2048): 

Tekrar ENTER

Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-1677721599, default 1677721599): 
Created a new partition 1 of type 'Linux' and of size 800 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Tekrar lsblk yapıyoruz ve partition adını kontrol ediyoruz.

NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0                         2:0    1    4K  0 disk 
loop0                       7:0    0   55M  1 loop /snap/core18/1880
loop1                       7:1    0 55.5M  1 loop /snap/core18/2284
loop2                       7:2    0 61.9M  1 loop /snap/core20/1328
loop3                       7:3    0 61.9M  1 loop /snap/core20/1361
loop4                       7:4    0 67.2M  1 loop /snap/lxd/21835
loop5                       7:5    0 43.6M  1 loop /snap/snapd/14978
loop6                       7:6    0 67.9M  1 loop /snap/lxd/22526
sda                         8:0    0  800G  0 disk 
└─sda1                      8:1    0  800G  0 part 
sdb                         8:16   0  200G  0 disk 
├─sdb1                      8:17   0    1M  0 part 
├─sdb2                      8:18   0    1G  0 part /boot
└─sdb3                      8:19   0  199G  0 part 
  └─ubuntu--vg-ubuntu--lv 253:0    0 99.5G  0 lvm  /
sr0                        11:0    1 1024M  0 rom  

İlgili kısmı ext4 olarak ayarlıyoruz

sudo mkfs -t ext4 /dev/sda1
mke2fs 1.45.5 (07-Jan-2020)
Discarding device blocks: done                            
Creating filesystem with 209714944 4k blocks and 52428800 inodes
Filesystem UUID: 47447a2a-01cd-4017-90ac-7997f08adc3e
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000

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

Şimdi disk UUID öğreniyoruz

sudo blkid
/dev/sdb2: UUID="52002d0b-d649-43ac-a6a7-c3ac14325414" TYPE="ext4" PARTUUID="b23cf6a1-ee3e-43bf-8cae-5df29bf6517b"
/dev/sdb3: UUID="OTBLr9-GVVp-4pj1-w29E-Luph-wP10-UeFDPo" TYPE="LVM2_member" PARTUUID="0cca0ec0-f495-46ff-9db1-fea170f9df6e"
/dev/mapper/ubuntu--vg-ubuntu--lv: UUID="73d228b7-de50-472f-8914-55aec9121bc1" TYPE="ext4"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/sdb1: PARTUUID="7067297d-4736-4eef-b161-87845e3d747e"
/dev/sda1: UUID="47447a2a-01cd-4017-90ac-7997f08adc3e" TYPE="ext4" PARTUUID="2ecefee3-01"

Ben bu diski /mnt/longhorn dizinine mount edeceğim. Bu nedenle şimdi klasörü oluşturuyorum

mkdir -p /mnt/longhorn

Şimdi kalıcı olarak boottan sonra mount olabilmesi için fstab’a ekleyelim. UUID adresinizi kopyalamayı unutmayın

nano /etc/fstab

En alta ekliyoruz

UUID=47447a2a-01cd-4017-90ac-7997f08adc3e /mnt/longhorn ext4 defaults 0 2

Kaydedip çıkıyoruz. Ardından mount ediyoruz.

mount -a
[email protected]:~# cd /mnt/longhorn/
[email protected]:/mnt/longhorn# ls -la
total 24
drwxr-xr-x 3 root root  4096 Feb 26 12:15 .
drwxr-xr-x 3 root root  4096 Feb 26 12:19 ..
drwx------ 2 root root 16384 Feb 26 12:15 lost+found

Booom!