tech:linux_server_new_drive
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tech:linux_server_new_drive [2026/09/06 10:00] – created katsimbris | tech:linux_server_new_drive [2026/10/01 16:33] (current) – add timeout katsimbris | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Adding a New Drive to the Ubuntu Server ====== | ====== Adding a New Drive to the Ubuntu Server ====== | ||
| - | This process is for adding a new storage drive to the Ubuntu server, formatting it as '' | + | This process is for adding a new storage drive to the Ubuntu server, formatting it as '' |
| The example below uses: | The example below uses: | ||
| Line 186: | Line 186: | ||
| <code bash> | <code bash> | ||
| - | echo ' | + | echo ' |
| </ | </ | ||
| Line 192: | Line 192: | ||
| This prevents a failed, disconnected, | This prevents a failed, disconnected, | ||
| + | |||
| + | '' | ||
| + | |||
| + | The combination: | ||
| + | |||
| + | < | ||
| + | nofail, | ||
| + | </ | ||
| + | |||
| + | means that Ubuntu will give the drive up to 60 seconds to appear, but will still continue booting if the drive is missing or unavailable. | ||
| The entry follows this format: | The entry follows this format: | ||
| < | < | ||
| - | UUID=FILESYSTEM-UUID /mnt/NAME ext4 defaults, | + | UUID=FILESYSTEM-UUID /mnt/NAME ext4 defaults, |
| </ | </ | ||
| Line 202: | Line 212: | ||
| < | < | ||
| - | UUID=a28ee7c4-9f5a-468a-a7aa-c82acdb2c798 /mnt/media8 ext4 defaults, | + | UUID=a28ee7c4-9f5a-468a-a7aa-c82acdb2c798 /mnt/media8 ext4 defaults, |
| </ | </ | ||
| - | ===== 9. Reload systemd ===== | + | ===== 9. Reload systemd |
| After changing ''/ | After changing ''/ | ||
| Line 211: | Line 221: | ||
| <code bash> | <code bash> | ||
| sudo systemctl daemon-reload | sudo systemctl daemon-reload | ||
| + | </ | ||
| + | |||
| + | Validate the '' | ||
| + | |||
| + | <code bash> | ||
| + | sudo findmnt --verify --verbose | ||
| + | </ | ||
| + | |||
| + | The important result is that there are no parse errors or errors. | ||
| + | |||
| + | Warnings may still appear for certain filesystem types or the swap file and do not necessarily indicate an invalid '' | ||
| + | |||
| + | For a media drive using the recommended settings, '' | ||
| + | |||
| + | < | ||
| + | userspace options: nofail, | ||
| </ | </ | ||
| Line 251: | Line 277: | ||
| /mnt/media8 /dev/sdi2 ext4 | /mnt/media8 /dev/sdi2 ext4 | ||
| </ | </ | ||
| + | |||
| + | ===== 11. Add the Drive as an SMB Share ===== | ||
| + | |||
| + | If the new drive should be accessible over the network, add it to Samba. | ||
| + | |||
| + | The media shares on this server use the following configuration: | ||
| + | |||
| + | < | ||
| + | [media8] | ||
| + | path = /mnt/media8 | ||
| + | browseable = yes | ||
| + | read only = no | ||
| + | valid users = mike | ||
| + | force group = media | ||
| + | create mask = 0664 | ||
| + | directory mask = 0775 | ||
| + | </ | ||
| + | |||
| + | Append the new share to ''/ | ||
| + | |||
| + | <code bash> | ||
| + | sudo tee -a / | ||
| + | [media8] | ||
| + | path = /mnt/media8 | ||
| + | browseable = yes | ||
| + | read only = no | ||
| + | valid users = mike | ||
| + | force group = media | ||
| + | create mask = 0664 | ||
| + | directory mask = 0775 | ||
| + | EOF | ||
| + | </ | ||
| + | |||
| + | Replace '' | ||
| + | |||
| + | Validate the Samba configuration: | ||
| + | |||
| + | <code bash> | ||
| + | sudo testparm | ||
| + | </ | ||
| + | |||
| + | A successful test should include: | ||
| + | |||
| + | < | ||
| + | Loaded services file OK. | ||
| + | </ | ||
| + | |||
| + | The new share should also appear in the service definitions shown by '' | ||
| + | |||
| + | If the configuration is valid, reload Samba: | ||
| + | |||
| + | <code bash> | ||
| + | sudo systemctl reload smbd | ||
| + | </ | ||
| + | |||
| + | Verify the underlying mount permissions: | ||
| + | |||
| + | <code bash> | ||
| + | ls -ld /mnt/media8 | ||
| + | </ | ||
| + | |||
| + | Expected ownership and permissions should look similar to: | ||
| + | |||
| + | < | ||
| + | drwxrwsr-x mike media /mnt/media8 | ||
| + | </ | ||
| + | |||
| + | The share can then be accessed from another computer using: | ||
| + | |||
| + | < | ||
| + | smb:// | ||
| + | </ | ||
| + | |||
| + | On macOS, use: | ||
| + | |||
| + | < | ||
| + | Finder → Go → Connect to Server | ||
| + | </ | ||
| + | |||
| + | The Samba settings work together with the filesystem permissions: | ||
| + | |||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * The setgid permission from '' | ||
| ===== Useful Commands ===== | ===== Useful Commands ===== | ||
| Line 282: | Line 394: | ||
| <code bash> | <code bash> | ||
| sudo blkid /dev/sdi2 | sudo blkid /dev/sdi2 | ||
| + | </ | ||
| + | |||
| + | Check that all expected media mounts are currently mounted: | ||
| + | |||
| + | <code bash> | ||
| + | for m in / | ||
| + | if mountpoint -q " | ||
| + | echo " | ||
| + | else | ||
| + | echo " | ||
| + | fi | ||
| + | done | ||
| + | </ | ||
| + | |||
| + | Validate ''/ | ||
| + | |||
| + | <code bash> | ||
| + | sudo findmnt --verify --verbose | ||
| + | </ | ||
| + | |||
| + | Validate the Samba configuration: | ||
| + | |||
| + | <code bash> | ||
| + | sudo testparm | ||
| + | </ | ||
| + | |||
| + | Reload Samba after making a configuration change: | ||
| + | |||
| + | <code bash> | ||
| + | sudo systemctl reload smbd | ||
| </ | </ | ||
| ===== Important Notes ===== | ===== Important Notes ===== | ||
| - | * Never format a drive until its identity has been confirmed using its size, model, serial number, existing filesystem, and mount status. | + | |
| - | * Do not rely on names such as ''/ | + | * Do not rely on names such as ''/ |
| - | * Permanent mounts should therefore use filesystem UUIDs in ''/ | + | * Permanent mounts should therefore use filesystem UUIDs in ''/ |
| - | * All external/ | + | * All external/ |
| + | * External/ | ||
| + | * The recommended combination for media drives is '' | ||
| + | * SMB shares should be validated with '' | ||
tech/linux_server_new_drive.1788703208.txt.gz · Last modified: by katsimbris
