美文网首页
Linux磁盘分区

Linux磁盘分区

作者: 老陕西 | 来源:发表于2019-12-04 11:15 被阅读0次

[root@host-10-1-234-164 puaiuc]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 410K 0 rom
vda 252:0 0 40G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 39G 0 part
├─centos-root 253:0 0 35.1G 0 lvm /
└─centos-swap 253:1 0 3.9G 0 lvm [SWAP]
vdb 252:16 0 100G 0 disk
└─vdb1 252:17 0 30G 0 part

##################################################################################
删除分区:
[root@host-10-1-234-164 puaiuc]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): d
Selected partition 1
Partition 1 is deleted

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
##################################################################################
创建60G分区

[root@host-10-1-234-164 puaiuc]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p^H
Partition number (1-4, default 1):
First sector (2048-209715199, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): +60G
Partition 1 of type Linux and of size 60 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
######################################################################

创建第二个分区

[root@host-10-1-234-164 puaiuc]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (2-4, default 2):
First sector (125831168-209715199, default 125831168):
Using default value 125831168
Last sector, +sectors or +size{K,M,G} (125831168-209715199, default 209715199): +39G
Partition 2 of type Linux and of size 39 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@host-10-1-234-164 puaiuc]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 410K 0 rom
vda 252:0 0 40G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 39G 0 part
├─centos-root 253:0 0 35.1G 0 lvm /
└─centos-swap 253:1 0 3.9G 0 lvm [SWAP]
vdb 252:16 0 100G 0 disk
├─vdb1 252:17 0 60G 0 part
└─vdb2 252:18 0 39G 0 part

####################################################################
格式化分区
[root@host-10-1-234-164 puaiuc]# mkfs.xfs /dev/vdb1 -f
meta-data=/dev/vdb1 isize=512 agcount=4, agsize=3932160 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=15728640, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=7680, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

#########################################################################
写分区表
echo "/dev/vdb1 /data xfs defaults 0 0" >> /etc/fstab

#########################################################################
手动查看
[root@host-10-1-234-164 puaiuc]# mkdir /data
[root@host-10-1-234-164 puaiuc]# mount /dev/vdb1 /data
[root@host-10-1-234-164 puaiuc]# ls /data
[root@host-10-1-234-164 puaiuc]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 36G 1.6G 34G 5% /
devtmpfs 7.9G 0 7.9G 0% /dev
tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs 7.9G 8.4M 7.9G 1% /run
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
/dev/vda1 1014M 127M 888M 13% /boot
tmpfs 1.6G 0 1.6G 0% /run/user/1000
/dev/vdb1 60G 33M 60G 1% /data
#########################################################################
[root@host-10-1-234-164 puaiuc]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 410K 0 rom
vda 252:0 0 40G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 39G 0 part
├─centos-root 253:0 0 35.1G 0 lvm /
└─centos-swap 253:1 0 3.9G 0 lvm [SWAP]
vdb 252:16 0 100G 0 disk
├─vdb1 252:17 0 60G 0 part
└─vdb2 252:18 0 39G 0 part

#############################################################

如果卷被占用,无法删除,则需要强制删除不用vg

dmsetup remove vg_94295d9ca438cfbc2caffc074e61cfdf-tp_7cef6c9ae149a4e0af2f65fbf3f1f16e_tdata

################################################################

允许root登录ssh

sed -i 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config

相关文章

  • 磁盘分区

    磁盘分区:linux磁盘分区主要分为三种:主磁盘分区、扩展磁盘分区、逻辑分区主分区:至少一个、最多4个,且主分区+...

  • 复习重点

    重点 主机规划与磁盘分区 各硬件装置在Linux中的文件名 p66 磁盘分区:课本例题 p67 磁盘分区表例...

  • Linux监控磁盘分区及使用情况的常用命令!

    Linux中监控磁盘分区及使用情况的命令有哪些?在Linux操作系统中,可用于监控磁盘分区及使用情况的命令有很多,...

  • linux入门常用指令

    ### linux磁盘分区 ![](./resources/a.jpg) #### boot分区 引导分区,存放引...

  • linux 挂载磁盘与分区lvm逻辑卷

    linux磁盘分区与挂载 1.1查看分区挂载情况,命令: 1.2创建新的磁盘分区 1.3保存分区表 1.4查看创建...

  • Linux常用命令之 - fdisk

    fdisk - Partition table manipulator for Linux 中文的意思是磁盘分区表...

  • linux文件系统

    Genaral windows使用磁盘分区等来进行管理,Linux下有文件管理标准FHS来进行规范。linux文件...

  • Linux基础知识有哪些

    Linux基础知识有哪些 一、Linux的磁盘分区及目录 Linux的配置是通过修改配置文件来完成。 1.1、Li...

  • Linux扩展分区和文件系统

    磁盘分区 linux也与windows一样,为了使用全部的磁盘空间,需要先对磁盘分区;如果所有分区的总容量小于磁盘...

  • 5 个免费的 Linux 分区管理器

    以下是我们推荐的 Linux 分区工具。它们能让你删除、添加、调整或缩放 Linux 系统上的磁盘分区。 通常,你...

网友评论

      本文标题:Linux磁盘分区

      本文链接:https://www.haomeiwen.com/subject/paikgctx.html