To change the EXT3 partition size in Linux

Source: Internet
Author: User
Article Title: Linux does not need to change the EXT3 partition size. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

This article describes how to perform lossless conversion on the size of the ext3 partition. The article details how to increase or decrease an existing ext3 partition and how to merge two ext3 partitions. This method is useful when you find that your existing partition scheme does not meet your actual needs and you do not want to use LVM. Of course, there are many different ways to achieve this goal, and I am using this method. Therefore, I do not guarantee that it applies to everyone.

1. Basic items:

Note that all the following commands must be executed as root. If you are an ubuntu user, use the sudo su command to switch your identity.

All the steps are tested in the ubuntu Edgy Eft desktop system. All the files in this system are located in a large partition (about 10 GB, device name/dev/sda1 ). Like this:

Df-h

Filesystem Size Used Avail Use % Mounted on

/Dev/sda1 9.5 GB 4.1G 4.9G 46%/

Varrun 94 M 132 K 94 M 1%/var/run

Varlock 94 M 0 94 M 0%/var/lock

Udev 10 M 52 K 10 M 1%/dev

Devshm 94 M 0 94 M 0%/dev/shm

Lrm 94 M 18 M 77 M 19%/lib/modules/2.6.17-10-generic/volatile

Partitions that need to be changed should be unmounted first (umount) before the operation. Obviously, if, for example, a partition containing all important system files, this operation is not feasible. Therefore, we need a live-CD, of course Linux, which can be used to start the system in a short time. Assume that your operation object is a remote system that cannot be actually accessed, you must ensure that you have a rescue system that can be started on the machine to replace live-CD, the following tools are also required: fdisk, umount, fsck, tune2fs, e2fsck, and resize2fs. According to the current situation, most host companies provide servers with rescue systems. If you need to re-allocate the size of the partition without any system files (such as/home partition, used for backup partition, etc.), you do not need to knoppixLive-CD or rescue system, all the steps described below can be executed directly.

If you want to deploy partitions in the work system, you must first back up your data, because once the size calculation of the new partition is incorrect, you may lose all the data, this is quite common when the partition size is reduced! For instructions on backup methods, refer to articles on the network.

I will re-partition/dev/sda1 in this tutorial. If your partition name is different from this one, replace/dev/sda1 with your partition name (for example,/dev/sdb5 or/dev/hda7 ).

2. Narrow down an ext3 Partition

This section describes how to narrow down an ext3 partition. In this example, I will narrow down my/dev/sda1. First, let's take a look at the current situation of the system:

Df

Filesystem 1K-blocks Used Available Use % Mounted on

/Dev/sda1 9859036 4234908 5123304 46%/

Varrun 95480 132 95348 1%/var/run

Varlock 95480 0 95480 0%/var/lock

Udev 10240 52 10188 1%/dev

Devshm 95480 0 95480 0%/dev/shm

Lrm 95480 17580 77900 19%/lib/modules/2.6.17-10-generic/volatile

Df-B 4 k

Filesystem 4K-blocks Used Available Use % Mounted on

/Dev/sda1 2464759 1058727 1280826 46%/

Varrun 23870 33 23837 1%/var/run

Varlock 23870 0 23870 0%/var/lock

Udev 2560 13 2547 1%/dev

Devshm 23870 0 23870 0%/dev/shm

Lrm 23870 4395 19475 19%/lib/modules/2.6.17-10-generic/volatile

Df-h

Filesystem Size Used Avail Use % Mounted on

/Dev/sda1 9.5 GB 4.1G 4.9G 46%/

Varrun 94 M 132 K 94 M 1%/var/run

Varlock 94 M 0 94 M 0%/var/lock

Udev 10 M 52 K 10 M 1%/dev

Devshm 94 M 0 94 M 0%/dev/shm

Lrm 94 M 18 M 77 M 19%/lib/modules/2.6.17-10-generic/volatile

Fdisk-l

Disk/dev/sda: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065*512 = 8225280 bytes

Device Boot Start End Blocks Id System

/Dev/sda1*1 1247 10016496 83 Linux

/Dev/sda2 1248 1305 465885 5 Extended

/Dev/sda5 1248 1305 465853 + 82 Linux swap/Solaris

Fdisk-s/dev/sda1

10016496

[1] [2] [3] [4] [5] [6] Next page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.