LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-04-2005, 08:12 AM   #1
kloss
Member
 
Registered: Nov 2004
Location: France & Germany
Distribution: (Pure) Debian Etch & Sid
Posts: 116

Rep: Reputation: 15
adding a partition - is it possible/safe ?


Hello all,
My / partition is now full, because some programs like "Duden" are installed in the /opt folder :
Code:
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda3             250M  237M  1.0K 100% /
/dev/hda9              18G  173M   17G   2% /home
/dev/hda8             361M  8.1M  334M   3% /tmp
/dev/hda5             4.6G  586M  3.8G  14% /usr
/dev/hda6             2.8G  308M  2.4G  12% /var
/dev/hda1              12G  9.0G  2.9G  77% /mnt/win
/dev/hda2              17G   11G  5.2G  68% /mnt/ubuntu
tmpfs                 252M     0  252M   0% /dev/shm
/dev/hdc              190M  190M     0 100% /media/cdrom0
I would like ot create a partition for /opt. Is it possible to do that? Is there any risk that I lose data?
++
Kloss
 
Old 12-04-2005, 08:21 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Assuming you have free disk space yes its possible. Use fdisk or one of the other partitioning utilties to create a partition for it on your free disk space. You then use mkfs to layout a filesystem on the partition then you mount the partition.

Prior to mounting the new partition as /opt you'd want to move the existing the directory:
mv /opt /opt.orig # Saves original /opt directory
mkdir /opt # Makes empty /opt directory (mount point)
mount <device> /opt # Mounts your partition (<device>) on the
new mount point.
cp -pR /opt.orig/* /opt # Recursively copies all the files and
directories from /opt.orig to the new
mounted partition.

Prior to doing above you want to stop all applications and verify no process is actively using /opt (lsof /opt will show you any that are).
 
Old 12-04-2005, 08:43 AM   #3
kloss
Member
 
Registered: Nov 2004
Location: France & Germany
Distribution: (Pure) Debian Etch & Sid
Posts: 116

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jlightner
Assuming you have free disk space yes its possible.
Thanks for your help.
I have no free space on my hdd, is it possible to resize an existing partition (for instance the ubuntu one) to free some space ?
(If so, I assume that the hdX will be different - hda3 becomes hda4 and so on -, but editing the fstab should solve this problem).
++
 
Old 12-04-2005, 09:03 AM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
In mounts the important thing is the device - you can mount it anywhere - the files within it become relative to the mount point.

For example if you had a file named /mnt/ubuntu/testfile in the mounted directory /mnt/ubuntu you could:

umount /mnt/ubuntu
mkdir /mountest
mount /dev/hda2 /mountest

The file would now be /mountest/testfile.

I'm not familiar with ubuntu so I'm not sure what /mnt/ubuntu is or if it is required. If its not then all you need to do is:

rm -rf /mnt/ubuntu/* # WARNING: Erases /mnt/ubuntu!!!
umount /mnt/ubuntu
mv /opt/orig.old /opt
mkdir /opt
mount /dev/hda2 /opt
cp -pR /opt/orig.old/* /opt

You'd then just edit the line in /etc/fstab that has hda2 going to /mnt/ubuntu to go to /opt instead. You wouldn't even need to mkfs on it unless you wanted to change the filesystem type. (Some people would do the mkfs after the rm -rf and umount just to make it more pristine but its not absolutely necessary.)
 
Old 12-04-2005, 09:16 AM   #5
kloss
Member
 
Registered: Nov 2004
Location: France & Germany
Distribution: (Pure) Debian Etch & Sid
Posts: 116

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jlightner
I'm not familiar with ubuntu so I'm not sure what /mnt/ubuntu is or if it is required. If its not then all you need to do is:

rm -rf /mnt/ubuntu/* # WARNING: Erases /mnt/ubuntu!!!
Actually I used ubuntu and was unhappy with it, so I installed Debian and now I have two Linux OS on my box. I don't use ubuntu anymore but I have some files on this partition and so far I have no reason to remove ubuntu. I don't know if I'm gonna use what you suggest (mounting /opt somewhere on the ubuntu partition) or resize this partition to free some space and do what you indicate in your first post. Maybe qtparted or Parition Magic can do that.
Thanks for your detailed explanations.
 
Old 12-04-2005, 11:33 AM   #6
kloss
Member
 
Registered: Nov 2004
Location: France & Germany
Distribution: (Pure) Debian Etch & Sid
Posts: 116

Original Poster
Rep: Reputation: 15
whouah... Here come the crash.
I was too lazy to install qparted and since I had partition magic on my win partition, I used it to create a new partition at the end of the hard drive and resizing/moving the others. Well, here ist the result.
When I rebooted, I got:
Code:
Grub loading stage 1.5
Grub loading, please Wait
error 17
I booted with a Debian netinst CD and saw that Partition Magic has freed 2GB of space on my HDD (before crashing). I installed Debian on this partition ; this reinstalled Grub on the MBR and I was able to boot my Ubuntu partition. But the (old) Debian install is not recognized. I think my "/" is fucked up :
Code:
root@ubuntu:/mnt # mount -t ext3 /dev/hda3 hda3/
mount: wrong fs type, bad option, bad superblock on /dev/hda3,
       missing codepage or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so
The other partitions, /usr, /var, /tmp, /home, are ok (I can mount them). Here you can find a screenshot which shows the actual state of my hdd.
So... What should I do now?
Thanks for your help
Kloss
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Safe to resize linux partition? Mackentack Linux - Newbie 4 05-02-2005 06:18 AM
Adding a new partition paul_dundee Linux - General 3 03-25-2005 05:51 PM
Adding a partition eddydw General 2 01-25-2005 01:43 PM
Safe to resize root partition with PM8? Ohmn Mandriva 6 07-09-2004 09:29 AM
Adding partition tommygunner Linux - General 11 07-11-2002 04:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration