Blame

1d4d54 J4nis05 2024-05-30 15:47:33 1
Here's a concise guide on how to format a drive as ext4 and mount it using UUID on a Debian system:
2
3
### 1. Identify the Drive
4
First, identify the drive you want to format. You can use the `lsblk` command:
5
```bash
6
lsblk
7
```
8
9
### 2. Format the Drive as ext4
10
Assuming your drive is `/dev/sdX` (replace `X` with the appropriate letter), format it as ext4:
11
```bash
12
sudo mkfs.ext4 /dev/sdX
13
```
14
15
### 3. Get the UUID of the Drive
16
Retrieve the UUID of the newly formatted drive:
17
```bash
18
sudo blkid /dev/sdX
19
```
20
Note the UUID, which will look something like `UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`.
21
22
### 4. Create a Mount Point
23
Create a directory where you want to mount the drive. For example:
24
```bash
25
sudo mkdir /mnt/mydrive
26
```
27
28
### 5. Edit the fstab File
29
Open the `/etc/fstab` file in a text editor:
30
```bash
31
sudo nano /etc/fstab
32
```
33
34
Add the following line at the end of the file, replacing `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` with the actual UUID and `/mnt/mydrive` with your desired mount point:
35
```bash
36
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/mydrive ext4 defaults 0 2
37
```
38
39
### 6. Mount the Drive
40
Mount all filesystems mentioned in `/etc/fstab` to apply the new configuration:
41
```bash
42
sudo mount -a
43
```
44
45
### 7. Verify the Mount
46
Check that the drive is mounted correctly:
47
```bash
48
df -h
49
```
50
51
You should see the drive listed with the mount point you specified.
52
53
That's it! You've successfully formatted the drive as ext4 and mounted it using its UUID.