-1

Apparently, I was using xvda1 disk which is out of space.

How do I change the /etc/fstab so that I can make my xvda2 for top level, and xvda1 as additional resource?

It's an EC2 instance:

root@~# cat /etc/fstab
LABEL=cloudimg-rootfs   /    ext4   defaults    0 0
/dev/xvda2  /mnt    auto    defaults,nobootwait,comment=cloudconfig 0   2

root@:/# du --max-depth=1 -h
4.0K    ./selinux
1.7G    ./opt
29M ./boot
du: cannot access `./proc/23342/task/23342/fd/4': No such file or directory
du: cannot access `./proc/23342/task/23342/fdinfo/4': No such file or directory
du: cannot access `./proc/23342/fd/4': No such file or directory
du: cannot access `./proc/23342/fdinfo/4': No such file or directory
0   ./proc
98M ./lib
13M ./etc
2.8M    ./home
72M ./run
8.0K    ./dev
4.0K    ./media
8.0M    ./sbin
20K ./mnt
4.0K    ./srv
0   ./tmp
8.3M    ./bin
1.4M    ./build
0   ./sys
1.4G    ./usr
3.9G    ./var
16K ./lost+found
233M    ./root
7.4G    .

root@:~# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1       8361916 7845404     97084  99% /
udev             1929404       8   1929396   1% /dev
tmpfs             773948   73672    700276  10% /run
none                5120       0      5120   0% /run/lock
none             1934860       0   1934860   0% /run/shm
overflow            1024      64       960   7% /tmp
/dev/xvda2     412814512  203156 391641580   1% /mnt

3 Answers3

3

If I were I would just replace it with a bigger one, with few minutes down time.

  1. Stop the instance
  2. In the console take snapshot of the root volume
  3. Create new ebs from that snapshot with bigger volume size
  4. detach the old volume and attach the new volume
  5. start your instance again
sumnulu
  • 145
  • 2
  • I am doing your suggestion. I get this error message in EC2. `Invalid value 'i-0fbd023c' for instanceId. Instance does not have a volume attached at root (/dev/sda1)` –  Nov 24 '12 at 22:14
  • The new volume has `/dev/sdf` and it's attached. –  Nov 24 '12 at 22:20
  • As I see from my instance info; `Block/Root Devices: sda1`, not the new one I created `sdf` –  Nov 24 '12 at 22:27
  • OK. I finally figured out. When I created my volume, I have assigned that to `/dev/sda1`, `/dev/sdf` cause error. Now, I increased the volume size. Thanks. –  Nov 24 '12 at 23:05
0

I guess this is EC2 instance (because xvda is what EC2 is using). In short, you can't do that in EC2.

Instead, you can permanently mount /dev/xvda2 (by editing /etc/fstab) at say, /home or /mnt and use it as an additional "pool" to put your data.

You can play with symlinks to try and split your data into 2 data sets of about the same size. Typically it is not difficult to get this to work.

mvp
  • 101
  • 5
0

Usually a unix/linux file system is split up into multiple partitions for /, /usr, /var, /home, /tmp and maybe /srv. If you cannot rebuild or repartition your system, look where the most space is used up and move that to your xvda2 partition. You can then bind mount or symlink parts of it into your file system.

For example, if your web space and mysql space are the biggest parts, you can

  • stop mysql and webserver
  • move /var/lib/mysql and /var/www to your /mnt partition
  • replace these directories with symlinks to /mnt/mysql and /mnt/www
  • restart mysql and webserver

Don't forget to backup your data, before playing around.

Olaf Dietsche
  • 275
  • 1
  • 7
  • should I move my /var to /mnt/var and symlink it? –  Nov 24 '12 at 21:33
  • I've done that, @Nizzy, it works fine, as long as you keep the permissions the same. –  Nov 24 '12 at 22:13
  • @Nizzy It looks like /opt and /var are the biggest prospects. Since /var is important for system operation, I'd look into /var and /var/lib with `du ...` and decide after that. – Olaf Dietsche Nov 24 '12 at 22:28