Partitioning script for rescue mode (disk size calculation)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Partitioning script for rescue mode (disk size calculation)
# 1  
Old 07-29-2008
Data Partitioning script for rescue mode (disk size calculation)

Hello!

I need to write partitioning script wich would work in rescue mode. It will prepare partitions and unpack linux on it. However I need to calculate whole size of the disk and create:

/dev/sda1 --> One big partition (minus (2*size of memory) for swap)
/dev/sda2 --> Swap partition (2*size of memory)

I know how to later do this using fdisk or sfdisk but how to get for example (disk size - (2*memory size)) the best would be in megabytes

free -m can give me memory size but

sfdisk -s gives disk size in blocks Smilie

fdisk -l give size (very nice) in GB
Disk /dev/sda: 750.1 GB, 750156374016 bytes

I'm confused how to calculate this properly. Can you help me??

Thank you in advance!
# 2  
Old 07-29-2008
Hello!

I found some script on other forum and rebuilt it.
It works
Code:
#!/bin/bash

DSIZE=`fdisk -l /dev/sda | grep "Disk /dev/sda" | cut -f 3 -d " " | awk -F "." {'print $1'}`
SWAPSIZE=4;
DATASIZE=$[$DSIZE-$SWAPSIZE];
echo "Disk size:               $DSIZE GB";
echo "Size for data partition: $DATASIZE GB";
echo "Size for swap partition: $SWAPSIZE GB";

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to fix and manage data in rescue mode?

Hello, I am running ubuntu 14.04 My server has problems again. I need to manage system files in rescue mode, backup some files, edit /etc/crontab and rc.local files etc. root@rescue:~# cat /proc/mdstat Personalities : md2 : active raid1 sda2 sdb2 4193216 blocks md3 :... (4 Replies)
Discussion started by: baris35
4 Replies

2. UNIX for Dummies Questions & Answers

How to get cpanel backup data in rescue mode?

How to get cpanel backup data in rescue mode? Server OS 6.3 minimal with cPanel /dev/sdb1 is main partition root@rescue ~ # fdisk -l Anyone can help Thank you (0 Replies)
Discussion started by: jaydul
0 Replies

3. Red Hat

You' dont have any Linux partition- Rescue Mode

I accidently deleted fstab file from one of the compute nodes of the cluster (RHEL 5.3). Due to this no filesystem/directory is mounted on the system during bootup. I started system in rescue mode but it says You don't have any linux partitions. Press return to get a shell. The system will reboot... (2 Replies)
Discussion started by: ahsanpmd
2 Replies

4. Red Hat

I cannot find ext2online or resize2fs in RHEL 4 rescue mode

Hi, I'm trying to resize an ext3 FS (filesystem) under an LVM. I have booted the OS (RHEL 4) in rescue mode using the CD media and I'm able to use lvm commands. Now, I'm trying to shrink the filesystem before actually shrinking the logical volume but I cannot find ext2onlone or resize2fs... (1 Reply)
Discussion started by: verdepollo
1 Replies

5. Red Hat

Disk partitioning commands for RHEL5

I'm new to Linux 5, going through initial phases of installation and setting up devices, etc,, and much to my surprise discovered also an existence of a 2nd hard drive to try to initialize and partition perhaps using any built-in command i.e. "fdisk" or similar, but I couldn't get the command to... (4 Replies)
Discussion started by: su
4 Replies

6. Solaris

Partitioning hard disk. Want 8 slices...have 9

Hi all I'm having difficulty setting up a proper disk structure on a 72GB HDD. The drive was previously part of a zfs pool. The zpool has ben destroyed and now I want to use the disk in a raid 5 array. I need to partition the disk accordingly though. This is what the partition table currently... (7 Replies)
Discussion started by: notreallyhere
7 Replies

7. Linux

Xen VM rescue mode

Hi all, I am running xen virtual machine on centos 5 and xen gust o.s is centos. I cannot boot my xen vm machine it saying cannot find /bin/sh to execute. I want to go to rescue mode of my xen vm machine. I know how to do on actual physical machine but how i can enter in rescue mode of... (6 Replies)
Discussion started by: email-lalit
6 Replies

8. Solaris

disk partitioning

Total disk size is 38912 cylinders Cylinder size is 32130 (512 byte) blocks Cylinders Partition Status Type Start End Length % ========= ====== ============ ===== === ====== === ... (2 Replies)
Discussion started by: seyiisq
2 Replies

9. UNIX and Linux Applications

Xen VM rescue mode

Hi all, I am running xen virtual machine on centos 5 and xen gust o.s is centos. I cannot boot my xen vm machine it saying cannot find /bin/sh to execute. I want to go to rescue mode of my xen vm machine. I know how to do on actual physical machine but how i can enter in rescue mode of... (1 Reply)
Discussion started by: email-lalit
1 Replies

10. UNIX for Dummies Questions & Answers

Hard Disk partitioning to use UNIX

Hello, To run UNIX, can the hard disk be partitioned so I could use that part for UNIX and the other for my existing Windows '98? At the moment there are hard drives C: & D:. Also, where can I obtain the UNIX software?.....Your response is appreciated. (2 Replies)
Discussion started by: hpin
2 Replies
Login or Register to Ask a Question