Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Sunday, October 26, 2014

Adding a new disk to an LVM Ubuntu system

Today I'm adding another disk to my main Linux server.

I used cgdisk to write a partition table. I set the partition type to 8e00 for LVM (Logical Volume Manager?)

sudo pvcreate /dev/sdb1

$ sudo lvcreate --extents 100%FREE -n lvdisk2 vgdisk2 
  Logical volume "lvdisk2" created

$ sudo vgcreate vgdisk2 /dev/sdb1

  Volume group "vgdisk2" successfully created

sudo mkdir /mnt/disk2
sudo mount /dev/vgdisk2/lvdisk2 /mnt/disk2/

And it's up!

Thursday, October 02, 2014

Ubuntu server maintenance

I'm doing some server maintenance today.

The main reason being that Ubuntu 13.10 systems are not updated to fix the Shellshock security hole, so I'll try to upgrade my main server to 14.04 or 14.10.

I had a full /boot partition first which I needed to fix. I had to move two initrd files (initrd.img-3.11.0-15-generic and initrd.img-3.11.0-17-generic) to /tmp temporarily to be able to fix it.

I then did an "apt-get install -f" to fix some broken package stuff, probably due to the full /boot partition.

I still got some out of diskspace errors, so I guess I have to move another initrd or two to /tmp:


run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.11.0-26-generic /boot/vmlinuz-3.11.0-26-generic
update-initramfs: Generating /boot/initrd.img-3.11.0-26-generic
gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.11.0-26-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.11.0-26
Rerunning "sudo apt-get -f install". It's very slow when doing "running depmod". Success! I now have 23M free on /boot. 

I'll try running apt-get autoremove. I now have 87 MB free on /boot.

I now do:

sudo apt-get purge linux-image-3.11.0-23-generic
sudo apt-get purge linux-image-3.11.0-24-generic
sudo apt-get purge linux-image-3.11.0-15-generic 
The last command removed the running kernel, which I hadn't really planned to do. Oh well. Now I have 155 MB free on /boot.

Actually, I got a bit worried, so I reinstalled the running kernel (3.11.0-15). 140 MB free.

Now I'll try again to upgrade to 14.04:

Hm. I did some kind of resurrect in the previously failed 14.04 installation window. I wonder if the installation restarted properly? I don't dare to interrupt it, so I'll let it run.

Rebooted after 240 days uptime. It is taking a very long time with the hard disk light on. I hope it is just a forced fsck.

For some reason the network didn't come up on the first boot, but after the next reboot.



Wednesday, August 14, 2013

Making a Raspberry Pi 3G Bridge / Hotspot

This post documents making a 3G Internet bridge / hotspot from a Raspberry Pi, a 3G modem, and a separate WiFi access point.

The purpose was to create an Internet connected WiFi-network at my parents' summer cottage.

I want to cover a fairly large area of the property and house. I might want several WiFi access points and control their placement and the placement of the 3G modem, therefore I did not want an integrated WiFi hub such as a Dovado 3/4G router (SEK 799 / €92 at Kjell & Co.

I'm using:
  • a Raspberry Pi model B (SEK 298 / €34 at Webhallen)
  • the Adafruit Occidentalis v 0.2 distribution (since I'd used it before)
  • an unlocked Huawei HiLink E353, originally tied to Swedish operator Tre, I think (SEK 179 / €21 at Swedish auction site Tradera)
  • Connected a WiFi access point I had earlier to the Raspberry Pi.
  • My plan is to use Telenor Bredband Kontant (SEK 400 / €46 for 6 months and 10 GB data). I did my tests by borrowing the SIM card from my iPad.
  • I think I also need a powered USB hub for the 3G modem, will experiment later to see if a more powerful supply for the Raspberry Pi might remove the need for this.
  • Normally, I used ssh over a network connection to the Raspberry Pi, but when setting up the network bridge, I used a regular monitor (with an HDMI - DVI cable) and a USB keyboard, because the network interfaces must be shut down to set up the bridge.
Installed Occidentalis on the SD card.

Connected RasPi to MacBook with Ethernet cable. Internet sharing from WiFi to Ethernet on MacBook, to give RasPi Internet access. Logged in with ssh on Raspberry Pi.

Booted the RasPi.
Did:
sudo apt-get update
sudo apt-get upgrade
(takes a long time)

usb_modeswitch is required to get 3G modem to work:
apt-get install usb-modeswitch
Install UPnP client, will be needed to open ports in the modem:
apt-get install miniupnpc
Remove and re-insert dongle?

Reboot:
sudo shutdown -r now
On startup, stick should be available as eth1, check with ifconfig. If it doesn't it might be that the modem needs to be in a powered USB hub.

edit /etc/network/interfaces

Add:
iface eth1 inet dhcp 
check with:
sudo ifup eth1
Great. Try to ssh into RasPi over public internet. How to get public IP?
wget http://ipecho.net/plain -O - -q ; echo
Got 90.129.85.242

Can't ssh to it (connection refused). After some research found out that in order to open port forwarding on the 3G modem, one must use UPnP.

Open port 22 to allow ssh connections from the Internet to the Raspberry Pi.
// to receive ssh
upnpc -r 22 TCP
Set up bridge (for more information, see documentation). This entails shutting down both network interfaces, so you will need to be connected to the Pi with keyboard & monitor, or with a third network connection:

I think I shut down eth0 and eth1 first:
ifdown eth0
ifdown eth1 
Then set up the bridge:
brctl addbr br0
brctl addif eth0
brctl addif eth1
dhclient br0
It works! Can access Internet via Dongle from WiFi. 

Modified my WiFi access point to have IP 192.168.1.2

Now set configuration in /etc/network/intefaces:
auto lo br0
iface lo inet loopback 

# Ethernet
iface eth0 inet manual

# Huawei 3G dongle
iface eth1 inet manual

allow-hotplug eth1

# Bridge
iface br0 inet dhcp
  bridge_ports eth0 eth1
  bridge_fd 0 # no forwarding delay

Configured DynDNS for my DNS provider Loopia according to these instructions. 

Works very nicely!

Did you find this useful? Please Flattr me!