add mount.md

This commit is contained in:
piccihud 2023-03-19 12:29:12 +01:00
parent 91fe79ef56
commit 1b14ed6534
1 changed files with 120 additions and 0 deletions

120
mount.md Normal file
View File

@ -0,0 +1,120 @@
# Formattare un device da terminale
## Identificare la periferica
Per identificare la periferica in questione si possono utilizzare diversi comandi:
```bash
sudo fdisk -l
sudo blkid
df
```
Ecco un esempio:
```bash
sudo blkid
[sudo] password di davide:
/dev/mapper/luks-44d72477-5d0f-4d0d-a54b-f721a7e5a320: UUID="cd370d97-dd7c-41d1-9b53-1504c89f64fd" TYPE="swap"
/dev/nvme0n1p1: UUID="487ce502-4541-488c-b07f-ea2ac4e91b9f" TYPE="crypto_LUKS" PARTUUID="0559b9a4-01"
/dev/nvme0n1p2: UUID="44d72477-5d0f-4d0d-a54b-f721a7e5a320" TYPE="crypto_LUKS" PARTUUID="0559b9a4-02"
/dev/mapper/luks-487ce502-4541-488c-b07f-ea2ac4e91b9f: UUID="ce884a78-4404-4ea9-b6e7-d543bfb38a41" BLOCK_SIZE="4096" TYPE="ext4"
/dev/sda1: BLOCK_SIZE="2048" UUID="2022-12-17-13-13-38-00" LABEL="d-live nf 11.6.0 kd amd64" TYPE="iso9660" PTUUID="66641822" PTTYPE="dos" PARTUUID="66641822-01"
/dev/sda2: SEC_TYPE="msdos" UUID="DEB0-0001" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="66641822-02"
```
oppure
```bash
df
File system 1K-blocchi Usati Disponib. Uso% Montato su
udev 7084012 0 7084012 0% /dev
tmpfs 1426036 2380 1423656 1% /run
/dev/dm-0 446217344 113436124 310041144 27% /
tmpfs 7130160 6748 7123412 1% /dev/shm
tmpfs 5120 16 5104 1% /run/lock
tmpfs 1426032 164 1425868 1% /run/user/1000
/dev/sda1 3600960 3600960 0 100% /media/davide/d-live nf 11.6.0 kd amd64
```
La chiavetta USB è identificata in questo caso come `/dev/sda` (/dev/sda1 e /dev/sda2 sono le due partizioni).
## Formattazione della periferica
Smontare la chiavetta USB:
```bash
sudo umount /dev/sda
```
### NTFS
Smontata la chiavetta dal sistema, digitare:
```bash
mkfs.ntfs /dev/sda -v
```
### EXT4
```bash
mkfs.ext4 /dev/sda -v
```
Un esempio:
```bash
sudo mkfs.ext4 -L "DAVIDE4GB" /dev/sda -v
mke2fs 1.46.6 (1-Feb-2023)
fs_types for mke2fs.conf resolution: 'ext4'
/dev/sda contains a ext4 file system
last mounted on Sun Mar 19 12:18:08 2023
Proceed anyway? (y,N) y
Filesystem label=DAVIDE4GB
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
237104 inodes, 947456 blocks
47372 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=970981376
29 block groups
32768 blocks per group, 32768 fragments per group
8176 inodes per group
Filesystem UUID: 62fd2424-ae9d-45f8-84d9-5a3b63020661
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
```
dove `-L` specifica il nome del filesystem, così che sia identificabile più facilmente. L'opzione `-v` indica *verbose*.
## Verificare la Formattazione
```bash
sudo fsck /dev/sda
sudo fsck /dev/sda
fsck da util-linux 2.38.1
e2fsck 1.46.6 (1-Feb-2023)
/dev/sda is mounted.
e2fsck: Cannot continue, aborting.
```
Oppure col comando:
```bash
sudo file -sL /dev/sda
```
## Collegamenti
- [https://www.chimerarevo.com/guide/linux-formattare-pendrive-usb-terminale-411029/](https://www.chimerarevo.com/guide/linux-formattare-pendrive-usb-terminale-411029/)
- [https://phoenixnap.com/kb/linux-format-usb](https://phoenixnap.com/kb/linux-format-usb)
- [https://wiki.archlinux.org/title/File_systems](https://wiki.archlinux.org/title/File_systems)
- [https://linuxhandbook.com/mkfs-command/](https://linuxhandbook.com/mkfs-command/)
- [https://www.thegeekdiary.com/mkfs-ext4-command-examples-in-linux/](https://www.thegeekdiary.com/mkfs-ext4-command-examples-in-linux/)