linux 分区扩展(linux手动分区)

老铁们,大家好,相信还有很多朋友对于linux 分区扩展和linux手动分区的相关问题不太懂,没关系,今天就由我来为大家分享分享linux 分区扩展以及linux手动分区的问题,文章篇幅可能偏长,希望可以帮助到大家,下面一起来看看吧!

Linux 已有四个主分区,怎么新增扩展分区

您好,理论上是不可以再新建分区了,所以您可以使用一些分区编辑软件将一个主分区或更多主分区转化为逻辑分区。也可以通过删除一个分区来创造一个新的逻辑分区。同时您要注意,这样的话,linux有可能因为分区的变化而无法启动。为了防止在操作中出现意外情况,您还是使用一些dos,pe或者linux live cd来改动。之后重建grub。分区操作比较危险,数据无价,谨慎操作。如有其他问题,欢迎追问。

redhat linux swap分区扩展的三种方法详解

redhat linux swap分区扩展的三种方法

swap介绍:

当物理内存占用完了后,当系统还需要更多的物理内存时,物理内存中inactive pages,就move到swap空间。swap空间是在位于硬盘上的,因此访问速度较物理内存慢。

当机器的物理内存发生变化时,swap分区也要做相应的扩展:

有三种方法可以对swap分区进行扩展:

一、扩展正在使用的swap分区的逻辑卷(推荐使用此种方式)

二、新建swap分区,

三、新建swap file,

具体步骤如下:

一、扩展正在使用的swap分区的逻辑卷

设定用作swap分区的逻辑卷为:/dev/VolGroup00/LogVol01

Disable swapping for the associated logical volume:

# swapoff-v/dev/VolGroup00/LogVol01

Resize the LVM2 logical volume by 256 MB:

# lvm lvresize/dev/VolGroup00/LogVol01-L+256M

Format the new swap space:

# mkswap/dev/VolGroup00/LogVol01

Enable the extended logical volume:

# swapon-va

Test that the logical volume has been extended properly:

# cat/proc/swaps或者# free

二、新建swap分区

设定新建的swap分区的逻辑卷为:/dev/VolGroup00/LogVol02

Create the LVM2 logical volume of size 256 MB:

# lvm lvcreate VolGroup00-n LogVol02-L 256M

Format the new swap space:

# mkswap/dev/VolGroup00/LogVol02

Add the following entry to the/etc/fstab file:

/dev/VolGroup00/LogVol02 swap swap defaults 0 0

Enable the extended logical volume:

# swapon-va

Test that the logical volume has been extended properly:

# cat/proc/swaps或者# free

三、新建swapfile

通过此种方式进行swap的扩展,首先要计算出block的数目。具体为根据需要扩展的swapfile的大小,以M为单位。block=swap分区大小*1024,例如,需要扩展64M的swapfile,则:block=64*1024=65536.

然后做如下步骤:

dd if=/dev/zero of=/swapfile bs=1024 count=65536

Setup the swap file with the command:

mkswap/swapfile

To enable the swap file immediately but not automatically at boot time:

swapon/swapfile

To enable it at boot time, edit/etc/fstab to include the following entry:

/swapfile swap swap defaults 0 0

After adding the new swap file and enabling it, verify it is enabled by viewing the output of the command cat/proc/swaps或者 free.

总结:三种方法都能对swap分区进行扩展,但是推荐使用第一种方法。

linux删除分区命令

linux系统下删除分区命令是什么呢?下面是具体介绍:

linux系统下删除分区命令是:fdisk命令。

1、fdisk命令简介:

fdisk- Partition table manipulator for Linux,译成中文的意思是磁盘分区表操作工具,其实就是分区工具。fdsik能划分磁盘成为若干个区,同时也能为每个分区指定分区的文件系统,比如linux、fat32、 linux、linux swap、fat16以及其实类Unix类操作系统的文件系统等;当然我们用fdisk对磁盘操作分区时,并不是一个终点,我们还要对分区进行格式化所需要的文件系统;这样一个分区才能使用;这和DOS中的fdisk是类似的。

2、fdisk操作硬盘的命令格式:

[root@localhost beinan]# fdisk设备

通过 fdisk-l得知/dev/hda或者/dev/sda设备;如果想再添加或者删除

一些分区,可以用

[root@localhost beinan]# fdisk/dev/hda

[root@localhost beinan]# fdisk/dev/sda

3、fdisk的说明:

通过 fdisk设备,进入相应设备的操作时,会有如下的提示。

[root@localhost beinan]# fdisk/dev/sda

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注:这是删除一个分区的动作;

l list known partition types注:l是列出分区类型,以供我们设置相应分区的类型;

m print this menu注:m是列出帮助信息;

n add a new partition注:添加一个分区;

o create a new empty DOS partition table

p print the partition table注:p列出分区表;

q quit without saving changes注:不保存退出;

s create a new empty Sun disklabel

t change a partitions system id注:t改变分区类型;

u change display/entry units

v verify the partition table

w write table to disk and exit注:把分区表写入硬盘并退出;

x extra functionality(experts only)注:扩展应用,专家功能;12345678910111213141516171819

举例:

列出当前操作硬盘的分区情况,用p:

Command(m for help): p

Disk/dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units= cylinders of 16128* 512= 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ c W95 FAT32(LBA)

/dev/sda2 26 125 806400 5 Extended

/dev/sda5 26 50 201568+ 83 Linux

/dev/sda6 51 76 200781 83 Linux123456789

通过fdisk的d指令来删除一个分区:

Command(m for help): p注:列出分区情况;

Disk/dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units= cylinders of 16128* 512= 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ c W95 FAT32(LBA)

/dev/sda2 26 125 806400 5 Extended

/dev/sda5 26 50 201568+ 83 Linux

/dev/sda6 51 76 200781 83 Linux

Command(m for help): d注:执行删除分区指定;

Partition number(1-6): 6注:我想删除 sda6,就在这里输入 6;

Command(m for help): p注:再查看一下硬盘分区情况,看是否删除了?

Disk/dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units= cylinders of 16128* 512= 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ c W95 FAT32(LBA)

/dev/sda2 26 125 806400 5 Extended

/dev/sda5 26 50 201568+ 83 Linux

Command(m for help):1234567891011121314151617181920

注意:删除分区时要小心,请看好分区的序号,如果您删除了扩展分区,扩展分区之下的逻辑分区都会删除;所以操作时一定要小心;如果知道自己操作错了,用q不保存退出;在分区操作错了时,千万不要输入w保存退出。

阅读剩余
THE END