Disk & File System
Disk Management Commands
| Bash |
|---|
| # find the file with system type
df -hT
# Disk usage for each directory
du -h -s * | sort -rh
# List Disk
lsblk
# List Partitions
fdisk -l
# Extend a partion
growpart /dev/nvme2n1 1
# mount a disk
mount /dev/nvme2n1p1 /newdir
# unmount
umount /newdir
# resize the file system (if XFS type)
xfs_growfs -d /newdir
# resize the file system (if EXT4 type)
resize2fs /dev/nvme2n1p1
# Get Raid active arrays
cat /proc/mdstat
|
File Management
| Bash |
|---|
| # Where Executable is located
which
chmod u+x [filename] #Add Execute to User to a file
chmod 330 [filename] #Set Read Write to User & Group
chown
# Number of files in a directory
ls | wc -l
# Create directory with a full path
mkdir -p [path]
# See Current directory
pwd
|
Install a new drive
Ref: https://help.ubuntu.com/community/InstallingANewHardDrive
| Bash |
|---|
| # List physical drive
lshw -C disk
# List all Drives (physical & virtual (Raid))
lsblk
|
Partition The Disk
| Bash |
|---|
| # Start parted as follows:
parted /dev/sdb
# Create a new GPT disklabel (aka partition table):
(parted) mklabel gpt
# set the partition size as a percentage of the disk
(parted) mkpart
Partition name? []? primary
File system type? [ext2]? ext4
Start? 0%
End? 100%
# Check that the results are correct:
(parted) print
(parted) quit
|
| Bash |
|---|
| # To format the new partition as ext4 file system (best for use under Ubuntu):
mkfs.ext4 -F /dev/sdb1
# he location from which you will access the drive
sudo mkdir /newstorage
|
Mount
manually mount
| Bash |
|---|
| mount /dev/sdb1 /newstorage
|
Add entry of fstab for Auto Mount on boot
| Bash |
|---|
| echo '/dev/sdb1 /newstorage ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab
|
Setup Samba
Ref: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-samba-share-for-a-small-organization-on-ubuntu-16-04
Install Samba
If Samba NetBIOS nmbd is not required, you can stop and disable it with systemctl
| Bash |
|---|
| systemctl stop nmbd.service
systemctl disable nmbd.service
|
To avoid security issues that can arise from running an unconfigured, network-enabled service, let’s stop the Samba server until configuration details
| Bash |
|---|
| systemctl stop smbd.service
|
Sambs Global Options
| Bash |
|---|
| mv /etc/samba/smb.conf /etc/samba/smb.conf.orig
|
| /etc/samba/smb.conf |
|---|
| [global]
server string = my_super_server
server role = standalone server
interfaces = lo eno1 (use: ip link)
bind interfaces only = yes
disable netbios = yes
smb ports = 445
log file = /var/log/samba/smb.log
max log size = 10000
|
| Bash |
|---|
| # Verify that smb.conf OK
testparm
|
Create User
| Bash |
|---|
| mkdir /storage/shared
adduser --home /storage/shared --no-create-home --shell /usr/sbin/nologin smb_user
chown smb_user:smb_user /storage/shared
chmod 2770 /storage/shared
# Add user to Samba
smbpasswd -a smb_user
# Enable the user
smbpasswd -e smb_user
# List users
pdbedit -L -v
|
Configuring the Samba Shares
| /etc/samba/smb.conf |
|---|
| ...
[share_name]
path = /storage/shared
browseable = no
read only = no
force create mode = 0660
force directory mode = 2770
valid users = smb_user
force user = smb_user
|
| Bash |
|---|
| # Verify that smb.conf OK
testparm
systemctl start smbd.service
|
Test with command line
| Bash |
|---|
| apt install smbclient
smbclient //your_samba_hostname_or_server_ip/share_name -U smb_user
|
Standard Directory
| Location |
Usage |
| /bin |
Essential User Binaries |
| /etc |
Configuration Files |
| /etc/opt |
Configuration files for add-on packages that are stored in |
| /home |
Home Folders |
| /lib |
Essential Shared Libraries |
| /opt |
Optional Packages |
| /root |
Root Home Directory |
| /sbin |
System Administration Binaries |
| /tmp |
Temporary Files |
| /usr |
User Binaries & Read-Only Data |
| /usr/bin |
Non-essential command binaries (not needed in single-user mode); for all users. |
| /usr/lib |
|
| /var |
Variable Data Files |
| /var/log |
Log files. Various logs. |
| /var/tmp |
Temporary files to be preserved between reboots. |
| /boot |
Static Boot Files |
| /dev |
Device Files |
| /mnt |
Temporary Mount Points |
| /proc |
Kernel & Process Files |
| /lost+found |
Recovered Files |
Reference
Other ref
AWS: Extend the file system after resizing an Amazon EBS volume
Set Up RAID on Ubuntu