Comment ajouter un disque externe vierge à un serveur Débian ?

Etape 1 : Localisation du disque avec la command fdisk :

# fdisk -l
Disk /dev/sda: 238,5 GiB, 256060514304 bytes, 500118192 sectors
Disk model: SMI             
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: B9D6E0E3-54C2-41BC-BBF8-3464FCE6A229

Device         Start       End   Sectors  Size Type
/dev/sda1       2048    999423    997376  487M EFI System
/dev/sda2     999424  98656255  97656832 46,6G Linux filesystem
/dev/sda3   98656256 469749759 371093504  177G Linux filesystem
/dev/sda4  469749760 500117503  30367744 14,5G Linux swap


Disk /dev/sdb: 111,8 GiB, 120034123776 bytes, 234441648 sectors
Disk model: KINGSTON SA400S3
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: 0x7ac27f0a

Device     Boot Start       End   Sectors   Size Id Type
/dev/sdb1        2048 234441647 234439600 111,8G 83 Linux


Disk /dev/sdc: 931,5 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Portable SSD T5 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33553920 bytes
Disklabel type: dos
Disk identifier: 0x7beb508f

Device     Boot Start        End    Sectors   Size Id Type
/dev/sdc1        2048 1953522112 1953520065 931,5G  7 HPFS/NTFS/exFAT

# fdisk -l  /dev/sdc1
Disk /dev/sdc1: 931,5 GiB, 1000202273280 bytes, 1953520065 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 33553920 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device      Boot      Start        End    Sectors  Size Id Type
/dev/sdc1p1      4294967295 8589934589 4294967295    2T ff BBT
/dev/sdc1p2      4294967295 8589934589 4294967295    2T ff BBT
/dev/sdc1p3      4294967295 8589934589 4294967295    2T ff BBT
/dev/sdc1p4      4294967295 6854241533 2559274239  1,2T ff BBT

La premiere commande localise mon nouveau disque, avec la seconde j’ai plus de détail.

Etape 2 : Formatage, pas question de laisser en mode Windows

# sudo mkfs.ext3 /dev/sdc1
mke2fs 1.44.5 (15-Dec-2018)
/dev/sdc1 contains a exfat file system labelled 'Samsung_T5'
Proceed anyway? (y,N) y
Creating filesystem with 244190008 4k blocks and 61054976 inodes
Filesystem UUID: 6db583fc-825f-4a0c-9ea5-dbb79bd6ae9f
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 (262144 blocks): done
Writing superblocks and filesystem accounting information: done 

Ou mieux en ext4 :

# sudo mkfs.ext4 /dev/sdc1
mke2fs 1.44.5 (15-Dec-2018)
/dev/sdc1 contains a ext3 file system
	created on Fri Nov 13 11:49:54 2020
Proceed anyway? (y,N) y
Creating filesystem with 244190008 4k blocks and 61054976 inodes
Filesystem UUID: bf1d9240-ba6d-4230-8e4e-dd20218231e8
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 (262144 blocks): done
Writing superblocks and filesystem accounting information: done  

Etape 3 : Le montage automatique :

# mkdir /media/usbdisk-1

Voir le uuid :

# ls -l /dev/disk/by-uuid/*
lrwxrwxrwx 1 root root 10 nov.  10 10:20 /dev/disk/by-uuid/1D2E-E63C -> ../../sda1
lrwxrwxrwx 1 root root 10 nov.  10 10:20 /dev/disk/by-uuid/5fa91220-4d17-485d-bb7d-3e41fc04e15b -> ../../sda2
lrwxrwxrwx 1 root root 10 nov.  10 10:20 /dev/disk/by-uuid/64b51c15-9706-4ac5-a369-774ce9539762 -> ../../sda3
lrwxrwxrwx 1 root root 10 nov.  13 15:05 /dev/disk/by-uuid/bf1d9240-ba6d-4230-8e4e-dd20218231e8 -> ../../sdc1
lrwxrwxrwx 1 root root 10 nov.  10 10:20 /dev/disk/by-uuid/c8478b72-fcaf-4dc7-87a7-5156cc19efab -> ../../sdb1
lrwxrwxrwx 1 root root 10 nov.  10 10:20 /dev/disk/by-uuid/d4f59815-be3d-437c-b204-ca794d170ce9 -> ../../sda4

Ajouter dans /etc/fstab :

UUID=bf1d9240-ba6d-4230-8e4e-dd20218231e8 /media/usbdisk-1 ext4 errors=remount-ro 0 1

Monter le disque ensuite :

# mount /media/usbdisk-1
# df -h
Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur
udev               3,9G       0  3,9G   0% /dev
tmpfs              783M     66M  718M   9% /run
/dev/sda2           46G    7,3G   37G  17% /
tmpfs              3,9G    8,0K  3,9G   1% /dev/shm
tmpfs              5,0M       0  5,0M   0% /run/lock
tmpfs              3,9G       0  3,9G   0% /sys/fs/cgroup
/dev/sdb1          110G     43G   62G  42% /mnt/backup
/dev/sda1          487M    5,2M  481M   2% /boot/efi
/dev/sda3          174G     30G  135G  19% /home
tmpfs              783M    4,0K  783M   1% /run/user/112
tmpfs              783M       0  783M   0% /run/user/1000
/dev/sdc1          916G     77M  870G   1% /media/usbdisk-1

C’est fini !

 

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Time limit is exhausted. Please reload CAPTCHA.