Solaris Changes File system size

Source: Internet
Author: User

As a system administrator, we often encounter the need to increase or decrease a file system. Dynamic Logical Volume Management (LVM) is a great help for the mainstream OS and Linux on UNIX. However, Solaris Systems that do not support LVM can only be implemented in a stupid way.

Assuming a work scenario, I need to add a separate file system to the server's hard drive, but there is no free space available on the hard drive. One alternative is to shrink a file system that already exists and squeeze out some free space.

The hard disk now has three file systems ("/", "/usr", "/export/home"):

# df-h

Filesystem size used avail capacity mounted on

/dev/dsk/c0d0s0 5.8G 3.8G 2.0G 66%/

/DEV/DSK/C0D0S3 6G 4G 2.0G 66%/usr

/dev/dsk/c0d0s7 12G 12M 11G 1%/export/home

where "/export/home" has the largest capacity, but has used minimal space, choose to shrink the file system to extrude free space.

Here are the steps to reduce the file system:

1. Backing up file system contents

# tar Cvf/home.tar/export/home

2. Uninstalling the file system

# Umount/export/home

3, modify the/etc/vfstab, note the file System entry

# Vi/etc/vfstab

#device device Mount FS fsck Mount Mount

#to mount to fsck point type Pass at boot options

#

#/dev/dsk/c0d0s7/dev/rdsk/c0d0s7/export/home UFS 2 Yes-

4. Reduce file system size with format

The format partition is used;
Partitioning and formatting be sure to master the Format tool, and now take the c0t11d0 disk as an example: after executing the format command, the results are shown as follows:
Searching for Disks...done
AVAILABLE DISK Selections:
0. c0t10d0 <sun18g cyl 7506 Alt 2 HD SEC 248> lzm
/sbus@3,0/sunw,fas@3,8800000/sd@a,0
1. c0t11d0 <sun18g cyl 7506 Alt 2 HD SEC 248>
/sbus@3,0/sunw,fas@3,8800000/sd@b,0
2. c0t12d0 <sun18g cyl 7506 Alt 2 HD SEC 248>
/sbus@3,0/sunw,fas@3,8800000/sd@c,0
3. c0t13d0 <sun18g cyl 7506 Alt 2 HD SEC 248>
/sbus@3,0/sunw,fas@3,8800000/sd@d,0


Specify disk (enter its number):
Select 1 and hit Enter to display the results as follows:
Specify disk (enter its number): 1
Selecting c0t11d0
[Disk formatted]
FORMAT MENU:
Disk-select a disk
Type-select (define) a disk type
Partition-select (define) a partition table
Current-describe the current disk
Format-format and analyze the disk
Repair-repair a defective sector
Label-write label to the disk
Analyze-surface Analysis
Defect-defect list Management
Backup-search for backup labels
Verify-read and Display labels
Save-save New Disk/partition Definitions
Inquiry-show Vendor, product and revision
Volname-set 8-character Volume name
!<cmd>-Execute <cmd>, then return
Quit
Format>
We can check the current partition situation, enter "P" after the return, the results are as follows:
format> P
PARTITION MENU:
0-change ' 0 ' partition
1-change ' 1 ' partition
2-change ' 2 ' partition
3-change ' 3 ' partition
4-change ' 4 ' partition
5-change ' 5 ' partition
6-change ' 6 ' partition
7-change ' 7 ' partition
Select-select a predefined table
Modify-modify a predefined partition table
Name-name the current table
Print-display the current table
Label-write partition map and label to the disk
!<cmd>-Execute <cmd>, then return
Quit
Partition>
The content presented here is the name of the partition you can select, select 0-7 to view the partition individually, you can also make partition name change, naming, marking, etc., when you enter "print" You can view the partition of the whole disk, as follows:
partition> Print or P
Current partition table (original):
Total disk Cylinders available:7506 + 2 (Reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 root WM 0-57 133.45MB (58/0/0) 273296
1 swap Wu 58-115 133.45MB (58/0/0) 273296
2 backup Wu 0-7505 16.86GB (7506/0/0) 35368272
3 Unassigned WM 0 0 (0/0/0) 0
4 Unassigned WM 0 0 (0/0/0) 0
5 Unassigned WM 0 0 (0/0/0) 0
6 usr wm 116-4606 10.09GB (4491/0/0) 21161592
7 Unassigned WM 4607-7455 6.40GB (2849/0/0) 13424488
Partition>
The place is presented is the whole disk partition situation, need to pay attention to several points: 1, the tag in the general can not be modified (how to modify it has not been studied); 2, clear the size of the disk, that isSize Column; 3, carefully study the next cylinders column, this class presents the cylinder usage of the disk, of which 2 is the entire disk of the cylinder interval data, the other partition is the occupancy of the partition, so we can according to the corresponding relationship to see if the disk has the remaining space can be used From the above results we can see that there are still 7456-7505 unused;
The situation described above is to determine the disk information, then proceed to partition operation, based on the above rendering results we can have two kinds of operations:
1. Enlarge or reduce the size of a partition;
At the "partition>" prompt, enter the partition number and return, rendering the result as follows:
Partition> 6
Part Tag Flag Cylinders Size Blocks
6 usr wm 116-4606 10.09GB (4491/0/0) 21161592
Enter partition ID TAG[USR]:
This link requires the input tag, you can enter directly, the next step is to enter the information: permission, starting cylinder and size, enter the required size to complete the partition operation; In the input size, in B, C, MB, GB units (note: The unit is lowercase); The return result is as follows:

Partition> 6
Part Tag Flag Cylinders Size Blocks
6 usr wm 116-4606 10.09GB (4491/0/0) 21161592
Enter partition ID TAG[USR]:
Enter partition permission FLAGS[WM]:
Enter New starting cyl[116]:
Enter partition size[21161592b, 4491c, 10332.81MB, 10.09GB]: 10.09GB

partition> Modify
Partition>label
Partition>quit
Format>save
To this partition operation is not completed, you need to name under partition, after entering the names still need the label, and then enter "Q" Exit to "format" to execute "save" to save the changes, to this location to expand or reduce the end of the partition;

2, re-partition operation;
Repartitioning requires the execution of the Modify command under "Partition", with the following results:
partition> Modify
Select Partitioning Base:
0. Current partition table (S6)
1. All Free Hog
Choose Base (enter number) [0]?
This link can be re-assigned to the S6, you can also re-partition the whole disk, (now take S6 as an example) directly after the return display as follows:
Choose Base (enter number) [0]?
Part Tag Flag Cylinders Size Blocks
0 root WM 0-57 133.45MB (58/0/0) 273296
1 swap Wu 58-115 133.45MB (58/0/0) 273296
2 backup Wu 0-7505 16.86GB (7506/0/0) 35368272
3 Unassigned WM 0 0 (0/0/0) 0
4 Unassigned WM 0 0 (0/0/0) 0
5 Unassigned WM 0 0 (0/0/0) 0
6 usr wm 116-4606 10.09GB (4491/0/0) 21161592
7 Unassigned WM 4607-7455 6.40GB (2849/0/0) 13424488
Do your wish to continue creating a new partition
Table based on above Table[yes]?
The default is yes, after carriage return prompts from 0-7 (without the hint of partition 6) the desired size, performed to this can be done on each partition of the data reconfiguration, executed sequentially after the results are as follows:
Do your wish to continue creating a new partition
Table based on above Table[yes]?
Free Hog partition[6]?
Enter size of partition ' 0 ' [273296b, 58c, 133.45MB, 0.13GB]: 0.15GB
Enter size of partition ' 1 ' [273296b, 58c, 133.45MB, 0.13GB]:
Enter size of partition ' 3 ' [0b, 0c, 0.00MB, 0.00GB]:
Enter size of partition ' 4 ' [0b, 0c, 0.00MB, 0.00GB]:
Enter size of partition ' 5 ' [0b, 0c, 0.00MB, 0.00GB]:
Enter size of partition ' 7 ' [13424488b, 2849c, 6554.93MB, 6.40GB]:
Part Tag Flag Cylinders Size Blocks
0 root WM 0-66 154.15MB (67/0/0) 315704
1 swap Wu 67-124 133.45MB (58/0/0) 273296
2 backup Wu 0-7505 16.86GB (7506/0/0) 35368272
3 Unassigned WM 0 0 (0/0/0) 0
4 Unassigned WM 0 0 (0/0/0) 0
5 Unassigned WM 0 0 (0/0/0) 0
6 usr wm 125-4606 10.07GB (4482/0/0) 21119184
7 Unassigned WM 4607-7455 6.40GB (2849/0/0) 13424488
Okay to make this partition Table[yes]?
On the prompt next to the car, confirm; enter "n" to cancel the operation; Pay attention to mark and save;
Operation to where the partition has been completed;
3. Logical formatting, which is usually referred to as advanced formatting (high-level FORMATTING,HLF or file system creation)
Creating a file system is a simple operation: You can execute the command directly: NEWFS/DEV/RDSK/C0T11D0S6 (c0t11d0s6 to new partition)
4. Hooking up the file system:
Execute command mount:mount/dev/dsk/c0t11d0s6/export/home/temp here to write the absolute path, and note that if the disk is made of the mirror must be written/dev/md/dsk the following device, otherwise it will cause the image data out of sync;
The above is described as a test result record, if necessary can follow the instructions to use, so far the partition and formatting have been described.

5. Reformat the file system with NEWFS

#cd/dev/dsk/

# NEWFS C0D0S7

Newfs:construct a new file System/dev/rdsk/c0d0s7: (y/n)? Y

warning:240 sector (s) in the last cylinder unallocated

/dev/rdsk/c0d0s7:12594960 sectors in 2050 cylinders of tracks, sectors

6149.9MB in 129 cyl groups (c/g, 48.00mb/g, 5824 i/g)

The reduced file system is 6G, freeing up about 6G of free space.

6. Recover/etc/vfstab File System entries

# Vi/etc/vfstab

#device device Mount FS fsck Mount Mount

#to mount to fsck point type Pass at boot options

#

/dev/dsk/c0d0s7/dev/rdsk/c0d0s7/export/home UFS 2 Yes-

Remove the "#" comment before the file system

7. Re-mount the file system

# Mount/export/home

8. Restore the backup to the file system

# tar Xvf/home.tar

9, since there is 6G of free space, the rest of the matter is good to do, I will not repeat.

The process of increasing the file system size is basically the same as shrinking, all following this basic idea:

Back up file system contents--Unmount File System--Change file system size--reformat file system--Re-mount--Restore original backup to file system.

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.