X
X
X
X

知识库

主页知识库Linux相关Ubuntu服务器创建用户并且分配磁盘空间

Ubuntu服务器创建用户并且分配磁盘空间

创建用户
sudo adduser test //创建
sudo adduser test sudo //给与新创建用户root权限(可选)
sudo smbpasswd –a test //创建samba用户,可以方便windows访问

为用户分配磁盘空间
利用fdisk命令进行磁盘分区,以下是相关参数:

Options:
-b, --sector-size physical and logical sector size
-B, --protect-boot don't erase bootbits when create a new label
-c, --compatibility[=] mode is 'dos' or 'nondos' (default)
-L, --color[=] colorize output (auto, always or never)
colors are enabled by default
-l, --list display partitions end exit //list当前系统中所有磁盘空间
-o, --output output columns
-t, --type recognize specified partition table type only
-u, --units[=] display units: 'cylinders' or 'sectors' (default)
-s, --getsz display device size in 512-byte sectors [DEPRECATED]
--bytes print SIZE in bytes rather than in human readable format

-C, --cylinders specify the number of cylinders
-H, --heads specify the number of heads
-S, --sectors specify the number of sectors per track

-h, --help display this help and exit
-V, --version output version information and exit

1. 选择需要分区的磁盘,李永命令sudo fdisk -l查看


这里我们选择磁盘/dev/sda分区,由上图可知,该磁盘已分两个分区。

2.磁盘分区
sudo fdisk /dev/sda

 

选择参数n,新建一个分区

 

这里,选择合适的分区大小,这里分为40G,K为KB,M为MB,G为GB,T为TB,P为PB。

3. 格式化分区


4. 挂载分区到用户
sudo mount -t ext4 /dev/sda3/ /home/test

利用df -h命令查看挂载情况

 

最后,为了在开机自动挂载分区,需要在/etc/fstab中添加挂载记录

echo "/dev/sda3 /home/test ext4 defaults 0 2 " >> /etc/fstab

找不到您要找的信息?

创建工单
你觉得有用吗?
(232 次查看/0人发现它有帮助)

Top